<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @fileOverview 表单文本域
 * @author dxq613@gmail.com
 * @ignore
 */

<span id='BUI-Form-Field-Number'>/**
</span> * 表单数字域
 * @class BUI.Form.Field.Number
 * @extends BUI.Form.Field
 */
var Field = require(&#39;./base&#39;),
  numberField = Field.extend({

<span id='BUI-Form-Field-Number-method-parseValue'>   /**
</span>   * 将字符串等格式转换成数字
   * @protected
   * @param  {String} value 原始数据
   * @return {Number}  该字段指定的类型
   */
  parseValue : function(value){
    if(value == &#39;&#39; || value == null){
      return null;
    }
    if(BUI.isNumber(value)){
      return value;
    }
    var _self = this,
      allowDecimals = _self.get(&#39;allowDecimals&#39;);
    value = value.replace(/\,/g,&#39;&#39;);
    if(!allowDecimals){
      return parseInt(value,10);
    }
    return parseFloat(parseFloat(value).toFixed(_self.get(&#39;decimalPrecision&#39;)));
  },
  _uiSetMax : function(v){
    this.addRule(&#39;max&#39;,v);
  },
  _uiSetMin : function(v){
    this.addRule(&#39;min&#39;,v);
  }
},{
  ATTRS : {
<span id='BUI-Form-Field-Number-property-max'>    /**
</span>     * 最大值
     * @type {Number}
     */
    max : {

    },
<span id='BUI-Form-Field-Number-property-min'>    /**
</span>     * 最小值
     * @type {Number}
     */
    min : {

    },
    decorateCfgFields : {
      value : {
        min : true,
        max : true
      }
    },
<span id='BUI-Form-Field-Number-property-validEvent'>    /**
</span>     * 表单元素或者控件触发此事件时，触发验证
     * @type {String}
     */
    validEvent : {
      value : &#39;keyup change&#39;
    },
    defaultRules : {
      value : {
        number : true
      }
    },
<span id='BUI-Form-Field-Number-property-allowDecimals'>    /**
</span>     * 是否允许小数，如果不允许，则最终结果转换成整数
     * @type {Boolean}
     */
    allowDecimals : {
      value : true
    },
<span id='BUI-Form-Field-Number-property-decimalPrecision'>    /**
</span>     * 允许小数时的，小数位
     * @type {Number}
     */
    decimalPrecision : {
      value : 2
    },
<span id='BUI-Form-Field-Number-property-step'>    /**
</span>     * 对数字进行微调时，每次增加或减小的数字
     * @type {Object}
     */
    step : {
      value : 1
    }
  }
},{
  xclass : &#39;form-field-number&#39;
});

module.exports = numberField;
</pre>
</body>
</html>
